package org.ubc.cs410.disposal2020.client.view;

import org.ubc.cs410.disposal2020.client.dto.GarbageDto;

import com.google.gwt.maps.client.geom.Point;
import com.google.gwt.maps.client.overlay.Icon;
import com.google.gwt.maps.client.overlay.Marker;
import com.google.gwt.maps.client.overlay.MarkerOptions;

/*
 * Garbage Marker Class 
 * Garbage Marker is the icon for garbage on the map
 */

public class GarbageMarker extends Marker {
	private static final String GARBAGE_ICON_PATH = "/garbage.png";
	private static final double GARBAGE_ICON_WIDTH = 32;
	private static final double GARBAGE_ICON_HEIGHT = 64;

	private GarbageDto g;

	public GarbageMarker(GarbageDto g) {
		super(g.getLocation(), initMarkerOptions(g));
		this.g = g;
	}

	public GarbageDto getGarbage() {
		return g;
	}

	private static MarkerOptions initMarkerOptions(GarbageDto g) {
		double multiplier = ((double)g.getAmount())/((double)g.getMaxAmount());
		Icon icon = Icon.newInstance(GARBAGE_ICON_PATH);
		icon.setIconAnchor(Point.newInstance((int)(GARBAGE_ICON_WIDTH*multiplier), (int)(GARBAGE_ICON_HEIGHT*multiplier)));
		MarkerOptions markerOptions = MarkerOptions.newInstance(icon);
		markerOptions.setDraggable(false);
		return markerOptions;
	}
}
